<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>借阅管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
            $("#btnExport").click(function () {
                top.$.jBox.confirm("确认要借阅记录吗？", "系统提示", function (v, h, f) {
                    if (v == "ok") {
                        $("#searchForm").attr("action", "${ctx}/book/borrowed/export");
                        $("#searchForm").submit();
                        $("#searchForm").attr("action", "${ctx}/book/borrowed/query");
                    }
                }, {buttonsFocus: 1});
                top.$('.jbox-body .jbox-icon').css('top', '55px');
            });
		});

		function getinfo(rdCardno) {
			window.open('${ctx}/book/borrowed/readerborrowlist?rdId='+rdCardno, 'selected', 'directorys=no,toolbar=no,status=no,menubar=no,resizable=no,width=750,height=500,top=150,left=200,scrollbars=yes');
		}

		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
			return false;
		}
		function btnClear() {
			$("#searchForm").find("input[type='text']").each(function () {
				$(this).val("");
			});
			$("#s2id_store").children("a").find(".select2-chosen").html("全部");
			$("#rdRoleId").val("");
		}
	</script>
</head>
<body>
<form:form id="searchForm" modelAttribute="borrow" action="${ctx}/book/borrowed/query" method="post" class="breadcrumb form-search ">
	<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
	<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
	<sys:tableSort id="orderBy" name="orderBy" value="${page.orderBy}" callback="page();"/>
	<ul class="ul-form">
		<li>
			<label>条码号：</label>
			<form:input path="bkId" htmlEscape="false" maxlength="50" class="input-medium"/>
		</li>
		<li>
			<label>借书证号：</label>
			<form:input path="rdCardno" htmlEscape="false" maxlength="50" class="input-medium"/>
		</li>
		<li>
			<label>一卡通号：</label>
			<form:input path="rdiccardno" htmlEscape="false" maxlength="50" class="input-medium"/>
		</li>
		<li>
			<label>ISBN：</label>
			<form:input path="isbn" htmlEscape="false" maxlength="50" class="input-medium"/>
		</li>
		<li>
			<label>读者姓名：</label>
			<form:input path="readername" htmlEscape="false" maxlength="50" class="input-medium"/>
		</li>
		<li>
			<label>读者类型：</label>
			<form:select path="rdRoleId" items="${fns:getAllReadRoleList()}" itemLabel="roleName"
						 itemValue="rdRoleId" cssStyle="width: 180px;" class="input-medium"/>
		</li>
		<li>
			<label>书名：</label>
			<form:input path="bookname" htmlEscape="false" maxlength="50" class="input-medium"/>
		</li>
		<li><label>分类号：</label>
			<form:input path="classcode" htmlEscape="false" maxlength="50" class="input-medium"/>
		</li>
		<li>
			<label>续借次数：</label>
			<form:input path="contCnt" htmlEscape="false" maxlength="50" class="input-medium"/>
		</li>
		<li>
			<label>借书日期：</label>
			<input id="borDate"  name="borDate"  type="text" readonly="readonly" maxlength="20" class="input-medium Wdate" style="width:163px;"
				   value="<fmt:formatDate value="${borrow.borDate}" pattern="yyyy-MM-dd"/>"
				   onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});"/>
		</li>
		<li>
			<label>应还日期：</label>
			<input id="needRtnDate"  name="needRtnDate"  type="text" readonly="readonly" maxlength="20" class="input-medium Wdate" style="width:163px;"
				   value="<fmt:formatDate value="${borrow.needRtnDate}" pattern="yyyy-MM-dd"/>"
				   onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});"/>
		</li>
		<li>
			<label>借书期间：</label>
			<input id="beginDate" name="beginDate"  type="text" readonly="readonly" class="input-medium Wdate" style="width:130px;"
				   value="<fmt:formatDate value="${borrow.beginDate}" pattern="yyyy-MM-dd"/>"
				   onclick="WdatePicker({dateFmt:'yyyy-MM-dd', maxDate:'#F{$dp.$D(\'endDate\')}'});"/>
			--
			<input id="endDate" name="endDate"  type="text" readonly="readonly" class="input-medium Wdate" style="width:130px;"
				   value="<fmt:formatDate value="${borrow.endDate}" pattern="yyyy-MM-dd"/>"
				   onclick="WdatePicker({dateFmt:'yyyy-MM-dd', minDate:'#F{$dp.$D(\'beginDate\')}'});"/>
		</li>
		<li>
			<label class="control-label">查询条件:</label>
			<form:select path="searchCondition" class="input-medium">
				<form:options items="${fns:getSearchDictList('bk_currentcirculation_search')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
			</form:select>
		</li>
		<li class="btns">
            <input id="btnSubmit" class="btn btn-primary" type="submit" value="查询" onclick="return page();">&nbsp;&nbsp;&nbsp;&nbsp;
            <input id="btnExport" class="btn btn-primary" type="button" value="导出"/>
			<a href="javascript:void(0)" onclick="btnClear()" class="btn">清空条件</a>
		</li>
		<li class="clearfix"></li>
	</ul>
</form:form>
<sys:message content="${message}"/>
<table id="contentTable" class="table table-striped table-bordered table-condensed">
	<thead>
	<tr>
		<th>借书证号</th>
		<th>一卡通号</th>
		<th>读者姓名</th>
		<th>联系电话</th>
		<th>图书条码</th>
		<th>资料名称</th>
		<th>价格</th>
		<th>ISBN</th>
		<th>索书号</th>
		<th>借出日期</th>
		<th>应还日期</th>
		<th>归还日期</th>
		<th>续借次数</th>
		<th>操作用户</th>
		<th>状态</th>
		<th>操作</th>
	</thead>
	<tbody>
	<c:forEach items="${page.list}" var="borrowlist">
		<tr>
			<td>${borrowlist.reader.rdCardno}</td>
			<td>${borrowlist.reader.rdIccardno}</td>
			<td>${borrowlist.reader.rdName}</td>
			<td>${borrowlist.reader.rdTele}</td>
			<td>${borrowlist.bkBookstore.banid}</td>
			<td>${borrowlist.bkBookinfo.bookname}<c:if test="${not empty borrowlist.bkBookinfo.othername}">-${borrowlist.bkBookinfo.othername}</c:if></td>
			<td>${borrowlist.bkBookstore.price}</td>
			<td>${borrowlist.bkBookinfo.isbn}</td>
			<td>${borrowlist.bkBookstore.classcode}/${borrowlist.bkBookstore.place}</td>
			<td><fmt:formatDate value="${borrowlist.borDate}" pattern="yyyy-MM-dd"/></td>
			<td><fmt:formatDate value="${borrowlist.needRtnDate}" pattern="yyyy-MM-dd"/></td>
			<td><fmt:formatDate value="${borrowlist.rtnDate}" pattern="yyyy-MM-dd"/></td>
			<td>${borrowlist.contCnt}</td>
			<td>${'self' eq borrowlist.source?'自助':borrowlist.userName}</td>
			<td>${fns:getDictLabel(borrowlist.status, 'borrow_status', '借出中')}</td>
			<td>
				<c:choose>
					<c:when test="${borrowlist.status== '1'}">
						<a href="${ctx}/book/borrowed/rtnbook?bookIds=${borrowlist.zlId}">归还</a>
						<a href="${ctx}/book/borrowed/brcontinue?id=${borrowlist.zlId}">续借</a>
					</c:when>
					<c:otherwise>
						--
					</c:otherwise>
				</c:choose>

			</td>
		</tr>
	</c:forEach>
	</tbody>
</table>
<div class="pagination">${page}</div>
</body>
</html>